tools: libxl: directly initialise saved_* in _libxl_types.c
authorIan Campbell <ian.campbell@citrix.com>
Thu, 8 Jan 2015 10:57:47 +0000 (10:57 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 12 Jan 2015 15:14:20 +0000 (15:14 +0000)
commit03f15f8d602efd974d4c3507c7f780cd6efaec40
tree9c87b269e275f03abe613a02002b6f8f68c3d8ca
parentc972bf4835c2c7d34c763ebe7c3023b6fd3d6177
tools: libxl: directly initialise saved_* in _libxl_types.c

Coverity complains:
> /tools/libxl/_libxl_types.c: 9194 in libxl__device_channel_parse_json()
> 9188             }
> 9189             x = libxl__json_map_get("connection.socket", o, JSON_MAP);
> 9190             if (x) {
> 9191                 libxl_device_channel_init_connection(p, LIBXL_CHANNEL_CONNECTION_SOCKET);
> 9192                 {
> 9193                     const libxl__json_object *saved_path = NULL;
> >>>     CID 1261758:  Unused value  (UNUSED_VALUE)
> >>>     Value from "x" is assigned to "saved_path" here, but that
> >>>     stored value is not used before it is overwritten.
> 9194                     saved_path = x;
> 9195                     x = libxl__json_map_get("path", x, JSON_STRING | JSON_NULL);
> 9196                     if (x) {
> 9197                         rc = libxl__string_parse_json(gc, x, &p->u.socket.path);
> 9198                         if (rc)
> 9199                             goto out;

Which we can avoid by initialising saved_%s as we define it. Resulting
in numerous instances of the generated code changing like this:
         if (x) {
             libxl_channelinfo_init_connection(p, LIBXL_CHANNEL_CONNECTION_PTY);
             {
-                const libxl__json_object *saved_path = NULL;
-                saved_path = x;
+                const libxl__json_object *saved_path = x;
                 x = libxl__json_map_get("path", x, JSON_STRING | JSON_NULL);
                 if (x) {
                     rc = libxl__string_parse_json(gc, x, &p->u.pty.path);

CID: 12617581261759 (and I would have expected others, but not
seeing them for some reason).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/gentypes.py